/*
 * @Author: ZhaoZhiqi
 * @Date: 2024-04-28 15:10:57
 * @LastEditors: ZhaoZhiqi
 * @LastEditTime: 2024-09-27 19:27:04
 * @Description: API
 * @FilePath: \parking-mini\src\api\api.js
 */
import http from "./http";

/**
 * @description: 登录
 * @param {String} code wx.login()回调code
 * @return {*}
 */
export const loginAPI = (data) =>
    http({
        url: `/app/da/getToken`,
        method: "GET",
        data,
    });

/**
 * @description: 获取哒哒验证码
 * @param {String} phoneNumber 手机号
 * @return {*}
 */
export const getVercodeAPI = (data) =>
    http({
        url: `/app/da/getNoteCode`,
        method: "GET",
        data,
    });

/**
 * @description: 获取哒哒token
 * @param {String} openid openid
 * @param {String} authData 手机号和验证码加密字符串
 * @return {*}
 */
export const getDadaTokenAPI = (data) =>
    http({
        url: `/app/da/login`,
        method: "POST",
        data,
    });

/**
 * @description: 获取哒哒平台订单，出口动态码和出口静态码
 * @param {String} inids 扫描二维码获取
 * @param {String} kind 扫描二维码获取
 * @param {String} token dada_token
 * @param {String} identifier 扫描二维码获取
 * @param {String} gate 扫描二维码获取
 * @return {*}
 */
export const getOrderDetailAPI = (data) =>
    http({
        url: `/app/da/getOrderOut`,
        method: "POST",
        data,
    });

/**
 * @description: 获取哒哒平台订单，场内静态码
 * @param {String} plate_number 车牌号
 * @param {String} token dada_token
 * @return {*}
 */
export const getOrderDetailByCarNumberAPI = (data, handleErrorFn) =>
    http({
        url: `/app/da/getOrderIn`,
        method: "POST",
        data,
        handleErrorFn,
    });

/**
 * @description: 生成哒哒支付订单
 * @param {String} orderNo 订单号
 * @param {String} amount 金额，分
 * @param {String} inid 扫码页面参数
 * @param {String} identifier 扫码页面参数
 * @param {String} openid openid
 * @param {String} token dada_token
 * @return {*}
 */
export const createDadaOrderAPI = (data, handleErrorFn) =>
    http({
        url: `/app/da/getPayOrder`,
        method: "POST",
        data,
        handleErrorFn,
    });

/**
 * @description: 获取哒哒平台缴费记录
 * @param {String} turnDirection 下一页传page_down
 * @param {String} excludeIds 上一页返回的excludeIds
 * @param {String} token dada_token
 * @return {*}
 */
export const getChargeOrderListAPI = (data) =>
    http({
        url: `/app/da/getChargeOrder`,
        method: "POST",
        data,
    });

/**
 * @description: 获取月卡缴费记录
 * @param {String} openId openId
 * @return {*}
 */
export const getVipOrderListAPI = (data) =>
    http({
        url: `/app/chargeOrder/getMonthCard`,
        method: "GET",
        data,
    });

/**
 * @description: 获取open_id
 * @param {*} data
 * @return {*}
 */
export const getPhoneNumberAPI = (data) =>
    http({
        url: `/app/user/getPhoneNumber`,
        method: "GET",
        data,
    });

/**
 * @description: 获取open_id
 * @param {*} data
 * @return {*}
 */
export const getOpenIdAPI = (data) =>
    http({
        url: `/app/user/getOpenId`,
        method: "GET",
        data,
    });

/**
 * @description: 获取所有停车场
 * @param {*} data
 * @return {*}
 */
export const getParkListAPI = (data) =>
    http({
        url: `/app/park/listAll`,
        method: "GET",
        data,
    });

/**
 * @description: 查询车牌
 * @param {*} data
 * @return {*}
 */
export const getPlateListAPI = (data) =>
    http({
        url: `/app/car/listAll`,
        method: "GET",
        data,
    });

/**
 * @description: 新增车牌
 * @param {*} data
 * @return {*}
 */
export const addPlateAPI = (data) =>
    http({
        url: `/app/car/add`,
        method: "POST",
        data,
    });

/**
 * @description: 删除车牌
 * @param {*} data
 * @return {*}
 */
export const removePlateAPI = (data) =>
    http({
        url: `/app/car/delete`,
        method: "POST",
        data,
    });

/**
 * @description: 查询订单支付状态
 * @param {String} token dada_token
 * @param {String} outTradeNo tradeNo
 * @return {*}
 */
export const queryOrderAPI = (data) =>
    http({
        url: `/app/da/getOrderStatus`,
        method: "POST",
        data,
    });

/**
 * @description: 下单
 * @param {*} data
 * @return {*}
 */
export const createOrderAPI = (data, handleErrorFn) =>
    http({
        url: `/app/da/getMonthCardPayOrder`,
        method: "POST",
        data,
        handleErrorFn,
    });

/**
 * @description: 续费 对应下单createOrderAPI
 * @param {*} data
 * @return {*}
 */
export const renewOrderAPI = (data, handleErrorFn) =>
    http({
        url: `/app/da/getMonthCardRenewOrder`,
        method: "POST",
        data,
        handleErrorFn,
    });

/**
 * @description: 新增月卡
 * @param {*} data
 * @return {*}
 */
export const buyVipAPI = (data) =>
    http({
        url: `/app/monthCard/add`,
        method: "POST",
        data,
    });

/**
 * @description: 更新月卡 对应新增月卡buyVipAPI
 * @param {*} data
 * @return {*}
 */
export const updateVipAPI = (data) =>
    http({
        url: `/app/monthCard/renew`,
        method: "POST",
        data,
    });

/**
 * @description: 查询月卡列表
 * @param {*} data
 * @return {*}
 */
export const getVipListAPI = (data) =>
    http({
        url: `/app/monthCard/allList`,
        method: "GET",
        data,
    });

/**
 * @description: 查询月卡详情
 * @param {*} data
 * @return {*}
 */
export const getVipDetailAPI = (data) =>
    http({
        url: `/app/monthCard/getById`,
        method: "GET",
        data,
    });

/**
 * @description: 更换车牌
 * @param {*} data
 * @return {*}
 */
export const updatePlateAPI = (data) =>
    http({
        url: `/app/monthCard/update`,
        method: "POST",
        data,
    });

/**
 * @description: 查询月卡列表
 * @param {*} data
 * @return {*}
 */
export const getPlanListAPI = (data) =>
    http({
        url: `/app/card/allList`,
        method: "GET",
        data,
    });

/**
 * @description: 查询广告列表
 * @param {*} data
 * @return {*}
 */
export const getAdListAPI = (data) =>
    http({
        url: `/app/ad/getEnableList`,
        method: "GET",
        data,
    });

/**
 * @description: 查询广告详情
 * @param {*} data
 * @return {*}
 */
export const getAdDetailAPI = (data) =>
    http({
        url: `/app/ad/getById`,
        method: "GET",
        data,
    });

/**
 * @description: 查询月卡类型
 * @return {*}
 */
export const getVipTypeListAPI = () =>
    http({
        url: `/app/card/allList`,
        method: "GET",
    });

/**
 * @description: 根据id查询月卡详情
 * @return {*}
 */
export const getVipTypeDetailAPI = (data) =>
    http({
        url: `/app/card/getDetail/${data.id}`,
        method: "GET",
    });

/**
 * @description: 根据月卡id查询月卡及用户月卡详情
 * @return {*}
 */
export const getVipCardDetailAPI = (data) =>
    http({
        url: `/app/monthCard/getRenewDetailById`,
        method: "GET",
        data,
    });

/**
 * @description: 查询未绑定月卡车牌列表
 * @return {*}
 */
export const getFreeCarNumberListAPI = (data) =>
    http({
        url: `/app/car/getFreeCarNumber`,
        method: "GET",
        data,
    });

/**
 * @description: 获取后台账密
 * @return {*}
 */
export const getAcountAPI = () =>
    http({
        url: `/app/da/getAccount`,
        method: "GET",
    });

/**
 * @description: 获取后台token
 * @return {*}
 */
export const getAcountTokenAPI = (data) =>
    http({
        url: `/app/da/loginPlatform`,
        method: "POST",
        data,
    });
